package com.lb.design.prototype;

import lombok.Data;

/**
 * @ClassName： Sheep
 * @Description：原型模式
 * @Author: 蓝莲花
 * @Date： 2024/1/16 14:17
 * @Version： V1.0
 */
@Data
public class Sheep implements Cloneable{
    private String name;
    private Integer age;
    private String color;

    public Sheep(String name, Integer age, String color) {
        this.name = name;
        this.age = age;
        this.color = color;
    }

    @Override
    public String toString() {
        return "Sheep{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", color='" + color + '\'' +
                '}';
    }

    @Override
    protected Object clone() {
        Sheep sheep = null;
        try {
            if (sheep == null) {
                sheep = (Sheep) super.clone();
            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
        return sheep;
    }
}